home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / SERIAL3.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  2KB  |  78 lines

  1. ;********************************;
  2. ; WASM Serial I/O, Block Input   ;
  3. ; By Eric Tauck                  ;
  4. ;                                ;
  5. ; Defines:                       ;
  6. ;                                ;
  7. ;   ComRea  read a block of data ;
  8. ;                                ;
  9. ; Requires:                      ;
  10. ;                                ;
  11. ;   SERIAL1.ASM                  ;
  12. ;   SERIAL5.ASM                  ;
  13. ;********************************;
  14.  
  15.         jmps    _serial3_end
  16.  
  17. ;========================================
  18. ; Read a block of serial data.
  19. ;
  20. ; In: BX= record address; AX= buffer
  21. ;     address; CX= bytes (non-zero); DX=
  22. ;     timeout ticks.
  23. ;
  24. ; Out: CY= set if bytes not all read; AX=
  25. ;      number of bytes read.
  26.  
  27. ComRea  PROC    NEAR
  28.         push    di
  29.         push    si
  30.         push    bp
  31.         push    cx              ;save bytes
  32.         mov     di, dx          ;save timeout value
  33.         mov     si, ax          ;save buffer address
  34.         mov     bp, bx          ;save record address
  35.  
  36. ;--- loop until all bytes loaded
  37.  
  38. _cmrea1 push    cx
  39.         mov     bx, bp          
  40.         call    ComGet          ;input a byte
  41.         pop     cx
  42.         jc      _cmrea3         ;jump if unavailable
  43.  
  44. _cmrea2 mov     [si], al        ;save byte
  45.         inc     si              ;increment pointer
  46.         loop    _cmrea1         ;loop back for next byte
  47.  
  48. ;--- finished, no timeout
  49.  
  50.         pop     ax              ;return bytes read
  51.         pop     bp
  52.         pop     si
  53.         pop     di
  54.         clc
  55.         ret
  56.  
  57. ;--- byte unavailable
  58.  
  59. _cmrea3 push    cx
  60.         mov     ax, di
  61.         mov     bx, bp
  62.         call    ComWai          ;wait for byte
  63.         pop     cx
  64.         jnc     _cmrea2         ;reenter read loop if available
  65.  
  66. ;--- finished, timeout
  67.  
  68.         pop     ax              ;return target bytes
  69.         sub     ax, cx          ;decrement for bytes not read
  70.         pop     bp
  71.         pop     si
  72.         pop     di
  73.         stc
  74.         ret
  75.         ENDP
  76.  
  77. _serial3_end
  78.